precision mediump float;
uniform samplerCube u_samplerCubeMap;
uniform mat4 u_matrixWVP;
uniform vec3 u_camPosition;
varying vec3 v_pos;
varying vec3 v_normalW;

void main(void)
{
	//gl_FragColor = textureCube(u_samplerCubeMap, v_pos);
	//gl_FragColor = textureCube(u_samplerCubeMap, vec3(v_pos.x, -v_pos.y, v_pos.z));
	
	vec3 toEye = u_camPosition - v_pos;
    vec3 reflectDir = reflect(normalize(-toEye), normalize(v_normalW));  // reflect() in non linear
    //gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
    gl_FragColor = textureCube(u_samplerCubeMap, reflectDir);
}